1 /* 2 Copyright: Marcelo S. N. Mancini (Hipreme|MrcSnm), 2018 - 2021 3 License: [https://creativecommons.org/licenses/by/4.0/|CC BY-4.0 License]. 4 Authors: Marcelo S. N. Mancini 5 6 Copyright Marcelo S. N. Mancini 2018 - 2021. 7 Distributed under the CC BY-4.0 License. 8 (See accompanying file LICENSE.txt or copy at 9 https://creativecommons.org/licenses/by/4.0/ 10 */ 11 module hip.hiprenderer.framebuffer; 12 import hip.hiprenderer.shader; 13 import hip.hiprenderer.renderer; 14 import hip.api.renderer.texture; 15 public import hip.api.renderer.framebuffer; 16 17 18 19 class HipFrameBuffer : IHipFrameBuffer 20 { 21 Shader currentShader; 22 protected IHipFrameBuffer impl; 23 int width, height; 24 this(IHipFrameBuffer fbImpl, int width, int height, Shader framebufferShader = null) 25 { 26 import hip.hiprenderer.initializer; 27 impl = fbImpl; 28 this.width = width; 29 this.height = height; 30 if(framebufferShader is null) 31 currentShader = newShader(HipShaderPresets.FRAME_BUFFER); 32 } 33 void create(uint width, uint height){} 34 void resize(uint width, uint height){} 35 36 void bind() 37 { 38 this.impl.bind(); 39 } 40 void unbind() 41 { 42 this.impl.unbind(); 43 } 44 void clear() 45 { 46 this.impl.clear(); 47 } 48 IHipTexture getTexture(){return impl.getTexture();} 49 50 void draw() 51 { 52 currentShader.bind(); 53 impl.draw(); 54 } 55 56 void dispose(){impl.dispose();} 57 58 } 59 60 61 package const float[24] framebufferVertices = //X, Y, S, T 62 [ 63 //First Quad 64 //Top Left 65 -1.0, -1.0, 0.0, 0.0, 66 67 //Top Right 68 1.0, -1.0, 1.0, 0.0, 69 70 //Bot Right 71 1.0, 1.0, 1.0, 1.0, 72 73 //Second quad 74 75 //Bot Right 76 1.0, 1.0, 1.0, 1.0, 77 78 //Bot Left 79 -1.0, 1.0, 0.0, 1.0, 80 81 //Top Left 82 -1.0, -1.0, 0.0, 0.0 83 ];